import { Injectable } from '@angular/core';


export class ConditionItem {
  public value:    number;
  public com:      string;
  public operator: string;

  constructor(
    public id:        number,
    public title:     string,
    public shortcut:  string,
    public condition: string,
  ) { }

  static formJSON(json: any): ConditionItem {
    let item = Object.create(ConditionItem.prototype);
    Object.assign(item, json);
    return item;
  }

  static toConditionItem(data: string): ConditionItem {
    let jsonData = JSON.parse(data);
    let item     = new ConditionItem(jsonData.id, jsonData.title, jsonData.shortcut, jsonData.condition);
    return item;
  }

  toJSON(): string {
    return '';
  }
}

export class CBCfg {
  id:        number;
  title:     string;
  shortcut:  string;
  condition: string;
};

export const cbCfgList: CBCfg[] = [
  {
    "id": 1,
    'title': 'When rank reach a position',
    "shortcut": "Rank",
    "condition": "range"
  },

  {
    "id": 2,
    "title": "When review rating changed",
    "shortcut": "Rating",
    "condition": "range"
  },

  {
    "id": 3,
    "title": "When review count changed",
    "shortcut": "Reviews",
    "condition": "range"
  },

  {
    "id": 4,
    "title": "When price changed",
    "shortcut": "Price",
    "condition": "range"
  },

  {
    "id": 5,
    "title": "When product listing is unavailable",
    "shortcut": "Available",
    "condition": "bool"
  }
];
